The 'for' loop is highly flexible. Its syntax is simply:
for (expression1 ; expression2 ; expression3)
statement
Expression1 is evaluated once upon entry to the loop, the statement is executed if expression2 evaluates to nonzero (true), and expression3 is evaluated at the end of each iteration of the loop. Most commonly, expression1 is used as the loop initialization, expression2 as the loop condition, and expression3 to increment a loop counter. For example:
for (i=0 ; i<10 ; i++)
process_things(i);
The comma operator is useful to implement multiple counters: